home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 3 code / Surf's Up! / Interfaces / CIncludes / CMIntf.h next >
Encoding:
Text File  |  1989-11-17  |  6.5 KB  |  255 lines  |  [TEXT/MPS ]

  1. //
  2. //    CMIntf.h
  3. //    C Interface to the Connection Manager
  4. //    
  5. //    Copyright © Apple Computer, Inc. 1988, 1989
  6. //    All rights reserved
  7. //
  8. //
  9.  
  10. #ifndef    __CMINTF__
  11. #define __CMINTF__
  12.  
  13. #ifndef __DIALOGS__
  14. #include <Dialogs.h>
  15. #endif
  16.  
  17. #ifndef __CTBUTILS__
  18. #include <CTBUtils.h>
  19. #endif
  20.  
  21. //    current Connection Manager version 
  22. #define    curCMVersion         1
  23.  
  24. //    current Connection Manager Environment Record version 
  25. #define    curConnEnvRecVers    0
  26.     
  27. // CMErr 
  28. typedef    OSErr CMErr;
  29.  
  30. #define cmGenericError         -1
  31. #define    cmNoErr                0
  32. #define cmRejected            1
  33. #define cmFailed            2
  34. #define cmTimeOut            3
  35. #define cmNotOpen            4
  36. #define cmNotClosed            5
  37. #define cmNoRequestPending    6
  38. #define cmNotSupported         7
  39. #define cmNoTools            8    
  40.  
  41.  
  42. // CMRecFlags and CMChannel
  43. //        Low word of CMRecFlags is same as CMChannel
  44. typedef long CMRecFlags;
  45. typedef short CMChannel;
  46.  
  47. enum {
  48.      cmData             = 1 << 0,
  49.     cmCntl             = 1 << 1,
  50.     cmAttn             = 1 << 2,
  51.     
  52.     cmDataClean     = 1 << 8,        
  53.     cmCntlClean        = 1 << 9,
  54.     cmAttnClean        = 1 << 10,
  55.  
  56. //        Only for CMRecFlags (not CMChannel) in the rest of this enum
  57.     cmNoMenus         = 1 << 16,    
  58.     cmQuiet            = 1 << 17
  59. };
  60.  
  61. //    connection status flags
  62. typedef long CMStatFlags;
  63.  
  64. enum {
  65.     cmStatusOpening        = 1 << 0,
  66.     cmStatusOpen         = 1 << 1,
  67.     cmStatusClosing     = 1 << 2,
  68.     cmStatusDataAvail     = 1 << 3,
  69.     cmStatusCntlAvail     = 1 << 4,
  70.     cmStatusAttnAvail     = 1 << 5,
  71.     
  72.     cmStatusDRPend         = 1 << 6,        // data read pending
  73.     cmStatusDWPend         = 1 << 7,        // data write pending
  74.     cmStatusCRPend         = 1 << 8,        // cntl read pending
  75.     cmStatusCWPend         = 1 << 9,        // cntl write pending
  76.     cmStatusARPend         = 1 << 10,        // attn read pending
  77.     cmStatusAWPend         = 1 << 11,        // attn write pending
  78.  
  79.     cmStatusBreakPend     = 1 << 12,
  80.     cmStatusListenPend     = 1 << 13,
  81.     cmStatusIncomingCallPresent 
  82.                         = 1 << 14
  83. };
  84.  
  85. //    CMBuffers    fields
  86. typedef short CMBufFields;
  87.  
  88. enum {
  89.     cmDataIn,
  90.     cmDataOut,
  91.     
  92.     cmCntlIn,
  93.     cmCntlOut,
  94.     
  95.     cmAttnIn,
  96.     cmAttnOut,
  97.     
  98.     cmRsrvIn,
  99.     cmRsrvOut
  100. };
  101.  
  102. typedef Ptr CMBuffers[8];
  103. typedef long CMBufferSizes[8];
  104.  
  105. //    CMSearchFlags
  106. typedef short CMSearchFlags;
  107.  
  108. enum {
  109.     cmSearchSevenBit =    1 << 0
  110. };
  111.  
  112. //    CMFlags (CMRead/Write deliminator flags)
  113. typedef short CMFlags;
  114. enum {
  115.     cmFlagsEOM        =    1 << 0
  116. };
  117.  
  118. struct ConnEnvironRec {
  119.     short        version;
  120.     long        baudRate;
  121.     short        dataBits;
  122.     CMChannel    channels;
  123.     Boolean        swFlowControl;
  124.     Boolean        hwFlowControl;
  125.     CMFlags        flags;
  126. };
  127. #ifndef __cplusplus
  128. typedef struct ConnEnvironRec ConnEnvironRec;
  129. #endif
  130.  
  131. typedef ConnEnvironRec *ConnEnvironRecPtr;
  132.  
  133. struct ConnRecord {
  134.     short        procID;
  135.     
  136.     CMRecFlags    flags;
  137.     CMErr        errCode;
  138.     
  139.     long        refCon;
  140.     long        userData;
  141.     
  142.     ProcPtr        defProc;
  143.     
  144.     Ptr            config;
  145.     Ptr            oldConfig;
  146.     
  147.     long        reserved0;
  148.     long        reserved1;
  149.     long        reserved2;
  150.  
  151.     Ptr            cmPrivate;
  152.  
  153.     CMBuffers        bufferArray;
  154.     CMBufferSizes    bufSizes;
  155.  
  156.     long        mluField;
  157.     
  158.     CMBufferSizes    asyncCount;
  159. };
  160.  
  161. #ifndef __cplusplus
  162. typedef struct ConnRecord ConnRecord;
  163. #endif
  164. typedef ConnRecord *ConnPtr, **ConnHandle;
  165.  
  166.  
  167. #ifdef __safe_link
  168. extern "C" {
  169. #endif    
  170. extern pascal CMErr        InitCM(void);
  171. extern pascal Handle     CMGetVersion(ConnHandle hConn);
  172. extern pascal short     CMGetCMVersion(void);
  173.  
  174. extern pascal ConnHandle    CMNew(short procID, CMRecFlags flags, CMBufferSizes desiredSizes, 
  175.                                 long refCon, long userData);
  176.  
  177. extern pascal void         CMDispose(ConnHandle hConn);
  178.  
  179. extern pascal CMErr     CMListen(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout);
  180. extern pascal CMErr     CMAccept(ConnHandle hConn, Boolean accept);
  181.  
  182. extern pascal CMErr     CMOpen(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout);
  183. extern pascal CMErr     CMClose(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout, Boolean now);
  184.  
  185. extern pascal CMErr     CMAbort(ConnHandle hConn);
  186.  
  187. extern pascal void         CMIdle(ConnHandle hConn);
  188. extern pascal CMErr     CMStatus(ConnHandle hConn, CMBufferSizes sizes, CMStatFlags *flags);
  189.  
  190. extern pascal void         CMReset(ConnHandle hConn);
  191.  
  192. extern pascal void         CMBreak(ConnHandle hConn, long duration, Boolean async, 
  193.                             ProcPtr completor);
  194.  
  195. extern pascal CMErr     CMRead(ConnHandle hConn, Ptr theBuffer, long *toRead, 
  196.                             CMChannel theChannel, Boolean async, ProcPtr completor, long timeout, 
  197.                             CMFlags *flags);
  198.  
  199. extern pascal CMErr     CMWrite(ConnHandle hConn, Ptr theBuffer, long *toWrite,
  200.                             CMChannel theChannel, Boolean async, ProcPtr completor, long timeout, 
  201.                             CMFlags flags);
  202.  
  203. extern pascal CMErr     CMIOKill(ConnHandle hConn, short which);
  204.  
  205. extern pascal void         CMActivate(ConnHandle hConn, Boolean activate);
  206. extern pascal void         CMResume(ConnHandle hConn, Boolean resume);
  207. extern pascal Boolean     CMMenu(ConnHandle hConn, short menuID, short item);
  208.  
  209. extern pascal Boolean     CMValidate(ConnHandle hConn);
  210. extern pascal void         CMDefault(Ptr *theConfig, short procID, Boolean allocate);
  211.  
  212. extern pascal Handle     CMSetupPreflight(short procID, long *magicCookie);
  213. extern pascal Boolean     CMSetupFilter(short procID, Ptr theConfig, short count, 
  214.                             DialogPtr theDialog, EventRecord *theEvent, short *theItem, 
  215.                             long *magicCookie);
  216. extern pascal void         CMSetupSetup(short procID, Ptr theConfig, short count, 
  217.                             DialogPtr theDialog, long *magicCookie);
  218. extern pascal void         CMSetupItem(short procID, Ptr theConfig, short count, 
  219.                             DialogPtr theDialog, short *theItem, long *magicCookie);
  220. extern pascal void         CMSetupCleanup(short procID, Ptr theConfig, short count, 
  221.                             DialogPtr theDialog, long *magicCookie);
  222. extern pascal void         CMSetupPostflight(short procID);
  223.  
  224. extern pascal Ptr         CMGetConfig(ConnHandle hConn);
  225. extern pascal short     CMSetConfig(ConnHandle hConn, Ptr thePtr);
  226.  
  227. extern pascal OSErr     CMIntlToEnglish(ConnHandle hConn, 
  228.                             Ptr inputPtr, Ptr *outputPtr, short language);
  229. extern pascal OSErr     CMEnglishToIntl(ConnHandle hConn, 
  230.                             Ptr inputPtr, Ptr *outputPtr, short language);
  231.  
  232. extern pascal long         CMAddSearch(ConnHandle hConn, const Str255 theString, 
  233.                             CMSearchFlags flags, ProcPtr callBack);
  234. extern pascal void        CMRemoveSearch(ConnHandle hConn, long refnum);
  235. extern pascal void        CMClearSearch(ConnHandle hConn);
  236.  
  237. extern pascal CMErr     CMGetConnEnvirons(ConnHandle hConn, ConnEnvironRec *theEnvirons);
  238.         
  239. extern pascal short     CMChoose(ConnHandle *hConn, Point where, ProcPtr idleProc);
  240. extern pascal void        CMEvent(ConnHandle hConn, const EventRecord *theEvent);
  241.  
  242. extern pascal void         CMGetToolName(short procID, Str255 name);
  243. extern pascal short     CMGetProcID(const Str255 name);
  244.  
  245. extern pascal void        CMSetRefCon(ConnHandle hConn, long refCon);
  246. extern pascal long         CMGetRefCon(ConnHandle hConn);
  247.  
  248. extern pascal long         CMGetUserData(ConnHandle hConn);
  249. extern pascal void         CMSetUserData(ConnHandle hConn, long userData);
  250.  
  251. #ifdef __safe_link
  252. }
  253. #endif
  254.  
  255. #endif